package com.yotoodesign.dianba.bean;

public class Song extends BaseData{
	public final static String PINYIN = "9";
	public final static String HUA = "0";
	public final static String YUE = "1";
	public final static String ENGLISH = "2";
	public final static String JAPAN = "3";
	public final static String TWO_SINGER = "4";
	
	
	/*
	 * 语种 0：华语、1：粤语、2：英文、3：日文
	 */
	private String languageType;
	/*
	 * 是否对唱 Y/N
	 */
	private boolean isTwoSinger;
	/*
	 * 歌词
	 */
	private String lrc;
	/*
	 * 歌词时间戳
	 */
	private String timestamp;
	/*
	 * 歌手
	 */
	private Singer singer = new Singer();
	
	
	
	public Song(){
		
	}
	
	public Song(String songName,String pinyin,Singer singer){
		this.setName(songName);
		this.setPinyin(pinyin);
		this.setSinger(singer);
	}
	
	public String toString(){
		return "songName="+this.getName()+",pinyin="
				+this.getPinyin()+",favoritesCount="+this.getFavoritesCount()
				+",singer="+singer.toString();
	}

	public String toXmlString(){
		StringBuffer result = new StringBuffer();
		result.append(XML_HEADER+CRLF);
		result.append("<songs>"+CRLF);
		result.append(TAB+"<song>"+CRLF);
		result.append(TAB+TAB+"<id>"+(this.getId()==null?"":this.getId())+"</id>"+CRLF);
		result.append(TAB+TAB+"<name>"+(this.getName()==null?"":this.getName())+"</name>"+CRLF);
		result.append(TAB+TAB+"<desc>"+(this.getDesc()==null?"":this.getDesc())+"</desc>"+CRLF);
		result.append(TAB+TAB+"<image_url>"+(this.getImageUrl()==null?"":this.getImageUrl())+"</image_url>"+CRLF);
		result.append(TAB+TAB+"<pinyin>"+(this.getPinyin()==null?"":this.getPinyin())+"</pinyin>"+CRLF);
		result.append(TAB+TAB+"<language_type>"+(this.getLanguageType()==null?"":this.getLanguageType())+"</language_type>"+CRLF);
		result.append(TAB+TAB+"<is_two_singer>"+(this.isTwoSinger()?"Y":"N")+"</is_two_singer>"+CRLF);
		result.append(TAB+TAB+"<favorites_count>"+this.getFavoritesCount()+"</favorites_count>"+CRLF);
		
		String ts = "";
		if(this.getTags()!=null){
			for(int i = 0 ;i<this.getTags().size();i++){
				ts += getTags().get(i).getName()+",";
			}
			if(ts.indexOf(",")!=-1){
				ts = ts.substring(0, ts.length()-1);
			}
		}
		
		result.append(TAB+TAB+"<tags>"+ts+"</tags>"+CRLF);
		
		result.append(TAB+TAB+"<lrc>"+(this.getLrc()==null?"":this.getLrc())+"</lrc>"+CRLF);
		result.append(TAB+TAB+"<timestamp>"+(this.getTimestamp()==null?"":this.getTimestamp())+"</timestamp>"+CRLF);
		result.append(TAB+TAB+"<create_date>"+(this.getCreateDate()==null?"":this.getCreateDate())+"</create_date>"+CRLF);
		result.append(TAB+TAB+"<update_date>"+(this.getUpdateDate()==null?"":this.getUpdateDate())+"</update_date>"+CRLF);
		result.append(TAB+TAB+"<singer>"+(this.getSinger()==null?"":this.getSinger().getId())+"</singer>"+CRLF);
		result.append(TAB+"</song>"+CRLF);
		result.append("</songs>"+CRLF);
		
		return result.toString();
	}


	public String getLanguageType() {
		return languageType;
	}

	public void setLanguageType(String languageType) {
		this.languageType = languageType;
	}

	public boolean isTwoSinger() {
		return isTwoSinger;
	}

	public void setTwoSinger(boolean isTwoSinger) {
		this.isTwoSinger = isTwoSinger;
	}

	public Singer getSinger() {
		return singer;
	}

	public void setSinger(Singer singer) {
		this.singer = singer;
	}

	public String getLrc() {
		return lrc;
	}

	public void setLrc(String lrc) {
		this.lrc = lrc;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

}
